package com.fqgj.sentry.common.exception;


import com.fqgj.common.api.enums.BasicErrorCodeEnum;
import com.fqgj.common.api.enums.ErrorCodeEnum;
import com.fqgj.exception.common.ApplicationException;
import com.fqgj.log.factory.LogFactory;

/**
 * Created by liupengpeng on 2017/7/13.
 */
public class BizException extends ApplicationException {
    private Integer errorId;

    public BizException(String message) {
        super(message);
        this.errorId = BasicErrorCodeEnum.INTERNAL_SERVER_ERROR.getCode();
    }

    public BizException(String message, Throwable cause) {
        super(message, cause);
        this.errorId = BasicErrorCodeEnum.INTERNAL_SERVER_ERROR.getCode();
        LogFactory.getLog(BizException.class).error("### error ###:: " + message, cause);
    }

    public BizException(ErrorCodeEnum errorCodeEnum) {
        super(errorCodeEnum.getMsg());
        this.errorId = errorCodeEnum.getCode();
    }

    public BizException(ErrorCodeEnum errorCodeEnum,String message) {
        super(message);
        this.errorId = errorCodeEnum.getCode();
    }

    public BizException(Integer errorId, String message, Throwable cause) {
        super(message, cause);
        this.errorId = errorId;
    }

    @Override
    public Integer getErrorId() {
        return errorId;
    }

    public BizException setErrorId(Integer errorId) {
        this.errorId = errorId;
        return this;
    }
}
